package org.llc.flink.study.collection.array

import scala.collection.mutable.ArrayBuffer


object ArrayTest {

  def main(args: Array[String]): Unit = {
    // 创建ArrayBuffer
    val arrBuf = ArrayBuffer[Any](3, 2, 5)

    // 通过下标访问数据
    println("arrBuf(1) = " + arrBuf(1))
    arrBuf.append(11, 12, 13)

    // 根据下标删除数据
    arrBuf.remove(5)

    // 遍历arrBuf
    for (item <- arrBuf) {
      println(item)
    }
  }

  def compare(x:Int, y:Int):Boolean = {
    x > y
  }

  //二维数组
  def array2(): Unit = {
    //声明一个二维数组，三行四列
    val arr = Array.ofDim[Int](3, 4)
    // 遍历二维数据arr
    for (i1 <- arr) { //取出二维数组的各个元素（一维数组）
      for (i2 <- i1) {
        print(i2)
      }
      println()
    }
  }
}
